package com.yiwyn;

import com.yiwyn.domain.User;
import ognl.Ognl;
import ognl.OgnlContext;
import ognl.OgnlException;

public class Main {
    public static void main(String[] args) throws OgnlException {

        User user = new User();
        user.setId(1);
        user.setName("Yiwyn");

        /*
        ognl三要素
        1. 上下文 context
        2. 表达式 expression
        2. root
         */
        OgnlContext context = Ognl.createDefaultContext(user);

        Object expression = Ognl.parseExpression("name");

        Object value = Ognl.getValue(expression, context, context.getRoot(), String.class);

        System.out.println(value);

    }
}